<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@include file="/static/common/taglib.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <title>181故障查询</title>
    <%@include file="../../public/commonCss.jsp" %>
    <%@include file="../../public/commonJs.jsp" %>
    <style>
        .layui-upload-button {
            height: 32px;
            line-height: 32px;
        }
    </style>
</head>
<body ms-controller="main" class="ms-controller">
<div id="wrapper">
    <div class="boxtoolbar whiteBox actionArea contentbox">
        <div class="layui-inline">
            <div class="layui-input-inline">
                <input type="text" ms-duplex="page.searchKey"
                       placeholder="车组号" class="layui-input"/>
            </div>
        </div>
        <div class="layui-inline">
            <div class="layui-input-inline">
                <button class="layui-btn layui-btn-normal layui-btn-small" ms-on-click="loadSearchData()">搜索</button>
            </div>
        </div>
        <div class="layui-inline">
            <div class="layui-input-inline">
                <button class="layui-btn layui-btn-small" onclick="exportExcel()">导出excel</button>
            </div>
        </div>
        <div class="layui-inline">
            <input type="file" class="layui-upload-file" name="file" lay-title="导入">
        </div>
    </div>
    <div class="boxmain whiteBox lrbox" style="margin-top:-90px">
        <div class="lrboxmain borderL" style="margin-left:0%">
            <div class="from-header borderB contentbox">
                <div>
                    <span class="font14"> 所属分类:</span><a id="category"><span class=" fontOrange2">车组号信息维护</span></a>
                </div>
            </div>
            <div class="from-body withheader contentbox" style=" overflow: auto;">
                <table class="layui-table">
                    <thead>
                    <tr>
                        <th>行号</th>
                        <th>更新时间</th>
                        <th>车型</th>
                        <th>车组号</th>
                        <th>当前走行公里</th>
                        <th>上次镟修走行公里</th>
                        <th>上次镟修后走行公里</th>
                        <th>上次二级修走行公里</th>
                        <th>前趟二级修项目分包</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr ms-repeat="tableData">
                        <td>{{(page.currentPage-1)*page.pageSize+$index+1}}</td>
                        <td>{{el.createTime}}</td>
                        <td>{{el.trainType}}</td>
                        <td>{{el.id}}</td>
                        <td>{{el.dqzxgl}}</td>
                        <td>{{el.scxxzxgls}}</td>
                        <td>{{el.scxxhzxgls}}</td>
                        <td>{{el.scejxzxgls}}</td>
                        <td>{{el.qtejxxmfb}}</td>
                    </tr>
                    </tbody>
                </table>
                <!-- 分页 -->
                <div id="demo" class="fenye">
                </div>
            </div>
        </div>
    </div>
    <!-- whitebox -->
</div>
<script type="text/javascript">
    var vm;
    avalon.ready(function () {
        vm = avalon.define({
            $id: "main",
            tableData: [],//图片数据
            page: {
                currentPage: 1,
                pageSize: 50,
                totalPage: 0,
                searchKey: ''
            }
        });
        avalon.scan();
        loadTableData();
    });

    //搜索
    function loadSearchData() {
        loadTableData();
    }

    //导出excel
    function exportExcel() {
        window.location.href = '${ctx}/trainNumInfo/exportTrainNumInfos.action'
    }

    layui.upload({
        url: '${ctx}/trainNumImport/importTrainNumInfos.action', //上传接口
        ext: 'xls',
        type: 'file',
        before: function (input) {
            layui.layer.load();
        },
        success: function (res) { //上传成功后的回调
            layerUtil.closeAll();
            if (res.code != 0) {
                layerUtil.confirm(res.msg);
            } else {
                layerUtil.success("导入成功");
                loadTableData();
            }
        }
    });

    //加载表格数据
    function loadTableData() {
        var dataStr = vm.$model.page;
        ajaxUtil.postDealCode("${ctx}/trainNumInfo/selectOnePage.action", dataStr, true, function (data) {
            vm.tableData = data.result;
            vm.page.totalPage = data.totalPage;
            pageUtil.renderPage(vm.page, loadTableData, "demo");
        });

    }
</script>
</body>
</html>